<template>
  <div class="row">
    <button class="sea-button" :class="[`sea-button-${type}`]" @click.self="handleClick">
      <i v-if="icon" :class="icon"></i>
      <span v-if="$slots.default">
        <slot></slot>
      </span>
    </button>
  </div>
</template>
<script>
export default {
  name: 'seaButton',
  props: {
    type: {
      type: String,
      default: 'default'
    },
    icon: {
      type: String,
      default: ''
    }
  },
  data () {
    return {}
  },
  mounted () {
    console.log(this.type, this.$slots)
  },
  methods: {
    handleClick () {
      this.$emit('on-click')
    }
  }
}
</script>
<style lang="scss" scoped>
.sea-button {
  //按钮默认样式的去除和简单的样式设置
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
  -webkit-appearance: none;
  text-align: center;
  box-sizing: border-box;
  outline: none;
  margin: 0;
  transition: 0.1s;
  font-weight: 500;
  // 禁止元素的文字被选中
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 4px;
  &:hover,
  &:focus {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
  }
}
.sea-button-primary {
  color: #fff;
  background-color: #409eff;
  border-color: #409eff;
  &:hover,
  &:focus {
    background: #66b1ff;
    border-color: 66b1ff;
    color: #fff;
  }
}
.sea-button-success {
  color: #fff;
  background-color: #67c23a;
  border-color: #67c23a;
  &:hover,
  &:focus {
    background: #85ce61;
    border-color: #85ce61;
    color: #fff;
  }
}
// 表示有sea-icon开头的图标的时候，给后面的span元素增加margin
.sea-button [class*=sea-icon-]+span {
  margin-left:5px;
}
</style>
